package sum.Controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import sum.Entity.Student;
import sum.Service.Impl.StudentServiceImpl;
import sum.Service.StudentService;

import javax.management.relation.Role;
import java.util.List;

@Controller
@RequestMapping("/student")
public class StudentController {
    @Autowired
    StudentService studentservice;
    @RequestMapping("/byConditions")
    public String getStudentsByConditions(Student student, Model model){
        List<Student> students = studentservice.queryByConditions(student);
        model.addAttribute("students",students);
        return "admin";
    }
    @RequestMapping("/byId")
    public String getStudentsById(String student_id, Model model){
        Student student1=studentservice.queryById(student_id);
        model.addAttribute("student",student1);
        return "student";
    }
    @RequestMapping("/byClass")
    public String getStudentsByClass(String stu_class, Model model){
        List<Student> students2=studentservice.queryByClass(stu_class);
        model.addAttribute("students",students2);
        return "teacher";
    }
    @RequestMapping("/edit")
    public String getStudentsByClass(Student student,Model model){
        studentservice.edit(student);
        Student student1=studentservice.queryById(student.getStudent_id());
        model.addAttribute("student",student1);
        return "student";
    }
}
